// 通过vue-router插件实现路由配置

import {createRouter,createWebHistory} from 'vue-router'
// 创建路由器
let route =createRouter({
    history:createWebHistory(),
    routes:[
        {
            path:'/login',
            // 组件使用的加载方法
            component:()=>import("@/views/login/index.vue"),
            name:"login"
        },
        {
            path:'/',
            // 组件使用的加载方法
            component:()=>import("@/views/layout/index.vue"),
             name:"layout",
             redirect:'/home',
             children:[
                {
                    path:'/home',
                    component:()=>import("@/views/home/Home.vue"),
                    meta:{title:'首页'}
                },
                {
                    path:'/user',
                    component:()=>import("@/views/user/User.vue"),
                    meta:{title:'用户管理'}
                },
                {
                    path:'/role',
                    component:()=>import("@/views/role/Role.vue"),
                    meta:{title:'角色管理'}
                },
                {
                    path:'/school',
                    component:()=>import("@/views/students/School.vue"),
                    meta:{title:'学校管理'}
                },
                {
                    path:'/class',
                    component:()=>import("@/views/students/Class.vue"),
                    meta:{title:'班级管理'}
                },
                {
                    path:'/major',
                    component:()=>import("@/views/students/Major.vue"),
                    meta:{title:'专业管理'}
                },
                {
                    path:'/student',
                    component:()=>import("@/views/students/Student.vue"),
                    meta:{title:'学生管理'}
                },
                {
                    path:'/student/update/:_id',
                    component:()=>import("@/views/students/UpDateStudent.vue"),
                    meta:{title:'添加/编辑学生'}
                },
             ]
        },
        {
            path:'/404',
            // 组件使用的加载方法
            component:()=>import("@/views/404/index.vue"),
             name:"404"
        },
        {
            path:"/:pathMatch(.*)*",
            redirect:"/404",
            name:'any'
        }
    ]
})
export default route